﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tester.DL645.Core;

namespace Tester.DL645.Responses
{
    /// <summary>
    /// 响应
    /// </summary>
    public class AbstractReponse:EventArgs
    {

        /// <summary>
        /// 
        /// </summary>
        public AbstractReponse()
        {
            this.Address = string.Empty;
        }

        /// <summary>
        /// 
        /// </summary>
        public Core.ResponseType ResponseType { get; protected set; }
        /// <summary>
        /// 
        /// </summary>
        public string Address { get; protected set; }


       public  byte[] Bytes { get; protected set; }

      public  string Description { get; protected set; }=string.Empty;
        /// <summary>
        /// 响应
        /// </summary>
        public AbstractReponse(byte[] buffer) {
           
            this.Bytes = buffer;
            this.Description = this.GetType().ToString() + buffer.Length + ":" + string.Join(" ", buffer.Select(item => item.ToString()));
            this.Address = AddressField.Reverse(buffer.Skip(1).Take(6).ToArray());
        }

        
    }
}
